package com.wbf.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
import org.springframework.session.web.http.HeaderHttpSessionIdResolver;
import org.springframework.session.web.http.HttpSessionIdResolver;


@SpringBootApplication
@EnableRedisHttpSession(maxInactiveIntervalInSeconds = 5*24*60*60)
@EnableCaching
/**
 * 启动类
 * @author fal
 * @EnableRedisHttpSession - 设置redisSession 过期时间，核心是一个filter拦截session获取方式，单位秒(5天)
 */
public class SecurityDemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(SecurityDemoApplication.class, args);
    }

    /**
     * 定义heard token名称
     * @return
     */
    @Bean
    public HttpSessionIdResolver httpSessionIdResolver() {
//        HeaderHttpSessionIdResolver.xAuthToken()
        return new HeaderHttpSessionIdResolver("token");
    }
}
